﻿using AntMovement.Core;
using System;
using System.Net.NetworkInformation;

namespace AntMovement.PCI1230
{
    public class Motion : IMotionBase
    {
        private int _index;
        public int Index => _index;
        private string _name;

        public string Name => _name;
        private long _status = -1;
        public Motion(string name, int index)
        {
            _name = name;
            _index = index;
        }

        public string Close()
        {
            _status = -1;
            CPcie1230.Pci1230Close(15);
            return "ok";
        }

        public long GetStatus() => _status;

        public string Open()
        {
            int error = CPcie1230.Pci1230Open(15);
            if (error == 1024)
            {
                _status = 0;
                return "ok";
            }
            return $"NG：{(PCI1230Error)error}";
        }
    }
}
